﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Model;

namespace DAL
{
    public  class Basic_InfoDAL:BaseDAL<Basic_Info>
    {
        public override string TableName
        {
            get { return "Basic_Info"; }
        }

        public override Dictionary<string, bool> PkName
        {
            get
            {

                Dictionary<string, bool> dic = new Dictionary<string, bool>();
                dic.Add("Basic_id", true);
                return dic;
            }
        }
        /// <summary>
        ///  项目立项显示
        /// </summary>
        /// <returns></returns>
        public List<Basic_Info> Basic_InfoGetLiXiang(Basic_Info info)
        {
            string sql = "select * from Basic_Info a join Department b on a.The_Department=b.Department_Id join Loan_Info c on a.ProjectNumber=c.ProjectNumber join Users on ";
            return DBHelper.ExecuteObjects<Basic_Info>(sql);
        }
        /// <summary>
        /// 修改开始勘察时间
        /// </summary>
        /// <param name="basic"></param>
        /// <returns></returns>
        public bool UpdateStartTime(Basic_Info basic)
        {
            string sql = "update Basic_Info set Survey_StartTime='"+basic.Survey_StartTime+"' where ProjectNumber='"+basic.ProjectNumber+"' ";
            return DBHelper.ExecuteNonQuery(sql)>0;
        }
        /// <summary>
        /// 修改结束勘察时间
        /// </summary>
        /// <param name="basic"></param>
        /// <returns></returns>
        public bool UpdateEndTime(Basic_Info basic) 
        {
            string sql = "update Basic_Info set Survey_EndTime='" + basic.Survey_StartTime + "' where ProjectNumber='" + basic.ProjectNumber + "'";
            return DBHelper.ExecuteNonQuery(sql) > 0;
        }
        /// <summary>
        /// 修改项目状态
        /// </summary>
        /// <param name="basic"></param>
        /// <returns></returns>
        public bool UpdateState(Basic_Info basic) 
        {
            string sql = "update Basic_Info set Basic_State='"+basic.Basic_State+"' where ProjectNumber='"+basic.ProjectNumber+"'";
            return DBHelper.ExecuteNonQuery(sql) > 0;
        }
    }
}
